import axios from 'axios'
// import router from '../router/index'
// import config from '../config.json'

// axios.defaults.baseURL = config.baseURL

axios.interceptors.request.use((conf) => {
  const { localStorage } = window
  const token = localStorage.adminToken || ''
  // eslint-disable-next-line
  conf.headers.authorization = `manager ${token}`
  return conf
})

// axios.interceptors.response.use((res) => {
//   if (res.data.status === 401) {
//     router.replace('/home')
//     return Promise.reject()
//   }
//   return res
// })

export default {
  LOGIN(loginData) {
    return axios.post('/manage/login', loginData)
  },
  // 一页30个
  GET_GOODS_BY_PAGE(page) {
    return axios.get(`/good/getGoods?page=${page}`)
  },
  GET_PAGE_COUNT() {
    return axios.get('/good/pageCount')
  },
  SAVE_TRANSLATION(translation) {
    return axios.post('/good/saveTranslation', { translation })
  }
}
